const app = getApp()
Page({
  data: {
    statusBar: app.globalData.statusBar,
    customBar: app.globalData.customBar,
    custom: app.globalData.custom,
    active: 0,
  },
  onLoad: function (options) {
    //创建节点选择器
    const that = this
    let swiper = wx.createSelectorQuery()
    swiper.select('#swiper').boundingClientRect()
    swiper.exec(function (res) {
      //res就是 所有标签为mjltest的元素的信息 的数组
      that.setData({
        swiperH: res[0].height,
      })
    })
  },
  // 切换
  _activeTab(e) {
    let active = e.target.dataset.type
    this.setData({ active })
  },
  // 跳转首页
  _toIndex() {
    wx.switchTab({
      url: '/pages/home/home',
    })
  },
  // 获取滚动条当前位置
  onPageScroll: function (e) {
    let that = this

    let scrollH = that.data.swiperH

    if (e.scrollTop <= scrollH) {
      this.setData({
        scrollRate: e.scrollTop / scrollH,
      })
    } else {
      this.setData({
        scrollRate: 1,
      })
    }
  },
})
